package homework.oopDay04;

public class PolymorphicDemo {
    public static void main(String[] args) {
        Animals[] animals = new Animals[4];
        animals[0] = new Dog("小黑",1,"黑");
        animals[1] = new Dog("小白",2,"白");
        animals[2] = new Fish("小粉",1,"粉");
        animals[3] = new Chick("🐤",2,"黄");
        for (int i = 0; i < animals.length; i++) {
            System.out.println(animals[i].name);
            animals[i].eat();
            animals[i].drink();
            if (animals[i] instanceof Dog){
                ((Dog) animals[i]).lookHome();
            }
            if (animals[i] instanceof Chick){
                ((Chick) animals[i]).layEgg();
            }
            if (animals[i] instanceof Swim){
                ((Swim) animals[i]).swim();
            }
        }
    }
}
